/*加载URL数据源到Select对象
 *obj:SELECT对象
 *url:指定URL
 *paras:向URL提交的参数
 *textfield:SELECT对象显示文本字段
 *valuefield:SELECT对象值字段
 *defaultvalue:默认值
 */
function loadURLData2Select(obj,url,paras,textfield,valuefield,defaultvalue,staticOption)
{
	loadXMLData2Select(obj,loadURLXMLData(url,paras),textfield,valuefield,defaultvalue,staticOption);
}

/*加载XML数据岛数据源到Select对象
 *obj:SELECT对象
 *xmlData:指定的XML数据
 *textfield:SELECT对象显示文本字段
 *valuefield:SELECT对象值字段
 *defaultvalue:默认值
 */
function loadXMLData2Select(obj,xmlData,textfield,valuefield,defaultvalue,staticOption)
{
	var xmlobj = new ActiveXObject("Microsoft.XMLDOM");
	xmlobj.async = false;
	xmlobj.loadXML(xmlData);
	var arrText  = xmlobj.getElementsByTagName(textfield);
	var arrValue = xmlobj.getElementsByTagName(valuefield);
	for (var i=0;i<obj.options.length;)
	{
		obj.remove(0);
	}
	var options = new Array();
	var j = arrText.length;
	var option = "";
	for (var i=0;i<j;i++)
	{
		if (arrValue(i).text==defaultvalue) 
			options[i] = "<option value=\""+arrValue(i).text+"\" selected>"+arrText(i).text+"</option>";
		else
			options[i] = "<option value=\""+arrValue(i).text+"\">"+arrText(i).text+"</option>";
	}
	end = new Date();
	var parentObj = obj.parentElement;
	var s = parentObj.innerHTML;
	var s1 = s.split("</SELECT>");
	if (staticOption == null || staticOption == "") {
		parentObj.innerHTML = s1[0]+options.join("")+"</SELECT>"+s1[1];
	} else {
		var staticOptions = staticOption.split("\|");
		parentObj.innerHTML = s1[0]+"<option value=\""+staticOptions[0]+"\" selected>"+staticOptions[1]+"</option>"+options.join("")+"</SELECT>"+s1[1];
	}
	
}


/*从指定URL中获取数据填充至TEXT
 *obj:TEXT对象
 *url:指定的URL对象
 *paras:向指定的URL提交的数据
 *textfield:显示在TEXT文本中的字段
 *defaultvalue:默认值
 */
function loadURLData2Text(obj,url,paras,textfield,defaultvalue)
{
	var xmlobj = new ActiveXObject("Microsoft.XMLDOM");
	xmlobj.async = false;
	xmlobj.loadXML(loadURLXMLData(url,paras));
	var arrText  = xmlobj.getElementsByTagName(textfield);
	if (arrText.length>0)
		obj.value = arrText(0).text;
	else
		obj.value=defaultvalue;
}


/*从指定URL中获取数据填充至TEXT
 *obj:TEXT对象
 *url:指定的URL对象
 *paras:向指定的URL提交的数据
 *textfield:显示在TEXT文本中的字段
 *defaultvalue:默认值
 */
function loadURLData2Var(url,paras,textfield,separate)
{
	/*
	var xmlobj = new ActiveXObject("Microsoft.XMLDOM");
	var _tmp="";
	xmlobj.async = false;
	xmlobj.loadXML(loadURLXMLData(url,paras));
	var arrText  = xmlobj.getElementsByTagName(textfield);
	for (var i=0;i<arrText.length;i++)
	{
		if (i==0)
			_tmp = arrText(i).text;
		else
			_tmp += separate + arrText(i).text;
	}
	return _tmp;
	*/
	//更新为使用数组
	var xmlobj = new ActiveXObject("Microsoft.XMLDOM");
	xmlobj.async = false;
	xmlobj.loadXML(loadURLXMLData(url,paras));
	var arrText  = xmlobj.getElementsByTagName(textfield);
	var _tmp = new Array();
	for (var i=0;i<arrText.length;i++)
	{
		_tmp[i] = arrText(i).text;
	}
	return _tmp.join(separate);
}


/*
 *获取指定URL的XML数据
 *url:指定的URL地址
 *paras:向指定的url要POST的数据
 *@return:url返回的数据
 */
function loadURLXMLData(url,paras)
{
	var oReq = new ActiveXObject("MSXML2.XMLHTTP");
	oReq.open("POST",encodeURI(url),false); 
	oReq.setRequestHeader("Content-Length",encodeURI(paras).length); 
	oReq.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded"); 
	oReq.send(encodeURI(paras));
	return oReq.responseText;
}

//通过Ajax方法提交数据并获得结果
function AjaxSubmit(_oForm)
{
	try
	{
		var _parameters = "";
		for (var i=0;i<_oForm.elements.length;i++)
		{
			if (_oForm.elements(i).type.toLowerCase() == "checkbox") {//checkbox如果选中则加入参数
				if (_oForm.elements(i).checked) {
					_parameters += "&"+_oForm.elements(i).name+"="+_oForm.elements(i).value;
				}
			} else if (_oForm.elements(i).type.toLowerCase() == "select-multiple") {//多选菜单
				for (var j=0;j<_oForm.elements(i).options.length;j++) {
					if (_oForm.elements(i).options[j].selected) {//选中则加入参数
						_parameters += "&"+_oForm.elements(i).name+"="+_oForm.elements(i).options[j].value;
					}
				}
			} else {
				_parameters += "&" + _oForm.elements(i).name+"="+_oForm.elements(i).value;
			}
		}
		//对参数处理,去掉&符号
		if (_parameters != "") {
			_parameters = _parameters.substring(1);
		}
		alert(loadURLXMLData(_oForm.action,_parameters));
	}
	catch(e)
	{
		alert(e);
		return false;
	}
	return false;
}

//获取Select对象的Text或Value
function GetStrFromSelectByText(obj)
{
	return obj.options[obj.selectedIndex].text;
}
function GetStrFromSelectByValue(obj)
{
	return obj.value;
}

/// void Go([iDelta=-1]);
/// 默认跳转方法(跳转的位置)
function Go(iDelta)
{
	//是新打开的窗口，并且没有历史窗口
	if(top==self && history.length==0)
	{
		top.close();
	}
	//不是新打开的窗口
	else
	{
        if(iDelta == null)
        {
            iDelta = -1;
        }
		history.go(iDelta);
	}
}//end Go()

//buildMmsFrame(序号,图片目录,图片文件,图片大小,内容,时间)
function buildMmsFrame(index,img_file_dir,img_file_name,img_file_size,mms_text,frame_time,read_only) {
	var s = "";
	s += "<p style=\"float:left;padding-left:2px;\">";
	if (read_only!="N") { 
		if (img_file_name != "")
			s += "<img style='cursor:hand;width:154px;height:112px' src='"+img_file_dir+"/"+img_file_name+"' width='99' height='84' border='0' onclick='PopDialog(oForm.imgFileDir"+index+",oForm.imgFileName"+index+",imgFileSize"+index+",this)'>";
		else 
			s += "<img style='cursor:hand;width:154px;height:112px' src='images/stand_by.gif' width='99' height='84' border='0' onclick='PopDialog(oForm.imgFileDir"+index+",oForm.imgFileName"+index+",imgFileSize"+index+",this)'>";
		s += "<input type='hidden' name='imgFileDir"+index+"' value='"+img_file_dir+"'/>";
		s += "<input type='hidden' name='imgFileName"+index+"' value='"+img_file_name+"'/>";
		s += "<input type='hidden' name='imgFileSize"+index+"' value='"+img_file_size+"'/>";
		s += "<br/>";
		s += "<textarea style='width:150px;height:100px' name='mmsText"+index+"' cols='20' rows='7' style='overflow:hidden;'>"+mms_text+"</textarea>";
		s += "</br>";
		if (frame_time == "")
			s += "<font style='vertical-align:middle'>时间：<input type='text' style='width:40px' name='frameTime"+index+"' value='10' size='3'>秒</font>";
		else
			s += "<font style='vertical-align:middle'>时间：<input type='text' style='width:40px' name='frameTime"+index+"' value='"+frame_time+"' size='3'>秒</font>";
		s += "</p>";
	} else {
		if (img_file_name != "")
			s += "<img style='cursor:hand;width:154px;height:112px' src='"+img_file_dir+"/"+img_file_name+"' width='99' height='84' border='0'>";
		else 
			s += "<img style='cursor:hand;width:154px;height:112px' src='images/stand_by.gif' width='99' height='84' border='0'>";
		s += "<input type='hidden' name='imgFileDir"+index+"' value='"+img_file_dir+"'/>";
		s += "<input type='hidden' name='imgFileName"+index+"' value='"+img_file_name+"'/>";
		s += "<input type='hidden' name='imgFileSize"+index+"' value='"+img_file_size+"'/>";
		s += "<br/>";
		s += "<textarea style='width:150px;height:100px' name='mmsText"+index+"' cols='13' rows='4' style='overflow:hidden;' readonly>"+mms_text+"</textarea>";
		s += "</br>";
		if (frame_time == "")
			s += "<font style='vertical-align:middle'>时间：<input type='text' style='width:40px' name='frameTime"+index+"' value='10' size='3' readonly>秒</font>";
		else
			s += "<font style='vertical-align:middle'>时间：<input type='text' style='width:40px' name='frameTime"+index+"' value='"+frame_time+"' size='3' readonly>秒</font>";
		s += "</p>";
	}
	return s;
}
//2010-4-24 闫振伟修改，目的：点击删除出现提示框
function ConfirmDeleteEvent(){
    return confirm("您确定要删除该数据吗？");
     
}
